package shop.services.front.organize.impl;

import org.springframework.stereotype.Service;
import shop.core.ServicesManager;
import shop.services.front.organize.OrganizeService;
import shop.services.front.organize.bean.Organize;
import shop.services.front.organize.dao.OrganizeDao;


import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/4/20.
 */
@Service("organizeServiceFront")
public class OrganizeServiceImpl extends ServicesManager<Organize, OrganizeDao> implements OrganizeService {
    @Resource(name = "organizeDaoFront")
    @Override
    public void setDao(OrganizeDao organizeDao) {
        this.dao = organizeDao;
    }

    @Override
    public Organize selectByPrincipalPhone(Organize organize) {
        return dao.selectByPrincipalPhone(organize);
    }

    @Override
    public List<Organize> selectSubList(Organize organize) {
        return dao.selectSubList(organize);
    }

    @Override
    public List<Organize> getRetroactiveList(Organize organize) {
        return dao.getRetroactiveList(organize);
    }

    @Override
    public List<Organize> getApprovalList(Organize organize) {
        return dao.getApprovalList(organize);
    }

    @Override
    /**
     * @return a:abc三级机构都需分佣,b:bc级机构分佣,c:c级机构分佣,d:只有志愿者分佣
     */
    public String getprofitType(String accountID) {
        Organize organize = dao.selectByAccount(accountID);
        if (organize != null) {
            Organize bOrganize = dao.selectSupList(organize);
            if (bOrganize != null) {
                Organize aOrganize = dao.selectSupList(bOrganize);
                if (aOrganize != null)
                    return "a";
                return "b";
            }
            return "c";
        }
        return "d";
    }

    @Override
    public Organize getSupOrganize(String id) {
        Organize organize = new Organize();
        organize.setId(id);
        return dao.selectSupList(organize);
    }
}
